Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few nits and clippy warnings #787

Merged
merged 7 commits into from
Jun 6, 2024
Merged

Few nits and clippy warnings #787

merged 7 commits into from
Jun 6, 2024

Conversation

correabuscar
Copy link
Contributor

No description provided.

--bin might've worked on cargo cca. 2018 ? unsure
but --example works today
cargo test --release

...if anyone ever tries that.
the following are fixed:

warning: redundant pattern matching, consider using `is_some()`
   --> /home/user/1tmp/ncurses_things/cursive/cursive-macros/src/builder/recipe.rs:354:16
    |
354 |         if let Some(_) = is_option_type(&field.ty) {
    |         -------^^^^^^^---------------------------- help: try: `if is_option_type(&field.ty).is_some()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
    = note: `#[warn(clippy::redundant_pattern_matching)]` on by default

warning: unneeded `return` statement
   --> /home/user/1tmp/ncurses_things/cursive/cursive-macros/src/builder/recipe.rs:576:9
    |
576 | /         return Ok(RecipeAttributes {
577 | |             base,
578 | |             base_parameters,
579 | |             name,
580 | |         });
    | |__________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
    |
576 ~         Ok(RecipeAttributes {
577 +             base,
578 +             base_parameters,
579 +             name,
580 ~         })
    |

warning: use of `unwrap_or_else` to construct default value
   --> /home/user/1tmp/ncurses_things/cursive/cursive-macros/src/builder/recipe.rs:561:49
    |
561 |         let mut name = base_default_name(&base).unwrap_or_else(String::new);
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
    = note: `#[warn(clippy::unwrap_or_default)]` on by default

warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> /home/user/1tmp/ncurses_things/cursive/cursive-core/src/views/dialog.rs:35:59
   |
35 |             if let Ok(string) = context.resolve::<String>(&config) {
   |                                                           ^^^^^^^ help: change this to: `config`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
   = note: `#[warn(clippy::needless_borrow)]` on by default

warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> /home/user/1tmp/ncurses_things/cursive/cursive-core/src/views/dialog.rs:43:56
   |
43 |             if let Ok(obj) = context.resolve::<Object>(&config) {
   |                                                        ^^^^^^^ help: change this to: `config`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
the following are fixed:

warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
   --> /home/user/1tmp/ncurses_things/cursive/cursive/src/backends/puppet/observed.rs:422:41
    |
422 |     fn get_observed_screen(fake_screen: &Vec<&str>) -> ObservedScreen {
    |                                         ^^^^^^^^^^ help: change this to: `&[&str]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
    = note: `#[warn(clippy::ptr_arg)]` on by default

warning: `cursive` (lib test) generated 1 warning
warning: statics have by default a `'static` lifetime
  --> /home/user/1tmp/ncurses_things/cursive/cursive/examples/autocomplete.rs:10:17
   |
10 | static CITIES: &'static str = include_str!("assets/cities.txt");
   |                -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
   = note: `#[warn(clippy::redundant_static_lifetimes)]` on by default
warnings fixed:

warning: manual implementation of `str::repeat` using iterators
  --> /home/user/1tmp/ncurses_things/cursive/cursive/examples/builder.rs:77:30
   |
77 |           let spaces: String = std::iter::repeat(" ")
   |  ______________________________^
78 | |             .take(cursor + "You wrote `".len())
79 | |             .collect();
   | |______________________^ help: try: `" ".repeat(cursor + "You wrote `".len())`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat
   = note: `#[warn(clippy::manual_str_repeat)]` on by default
@correabuscar correabuscar changed the title Few nits Few nits and clippy warnings Jun 6, 2024
@gyscos gyscos merged commit 332a6a4 into gyscos:main Jun 6, 2024
1 check passed
@gyscos
Copy link
Owner

gyscos commented Jun 6, 2024

Thanks for the work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants